package com.example.demofdfs.test.obj;

import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ProdcuterQueue {

	Queue<Prodcute> queue = new LinkedList<ProdcuterQueue.Prodcute>();
	Lock lock = new ReentrantLock();
	Condition condition = lock.newCondition();
	
	public void set(Prodcute object) {
		lock.lock();
		if (queue.isEmpty()) {
			queue.offer(object);
		}
		lock.unlock();
	}
	
	public Prodcute get() {
		return queue.poll();
	}
	
	static class Prodcute {
		
		private int id;
		private String name;
		public Prodcute(int id, String name) {
			super();
			this.id = id;
			this.name = name;
		}
	}
	
}
